package com.wanwu.channel.biz.channel;

import com.wanwu.channel.biz.TradeOrder;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class AliPayParameterService extends PayParameterService {
    @Override
    public Map<String, Object> getPayParameter(String tradeNo) {
        TradeOrder tradeOrder = queryTradeOrder(tradeNo);

        Map<String, Object> bizContent = new HashMap<>();
        bizContent.put("total_amount", tradeOrder.getTotalFee());
        bizContent.put("mchid", tradeOrder.getMerchantCode());
        bizContent.put("subject", tradeOrder.getGoodsBody());
        bizContent.put("out_trade_no", tradeOrder.getOutTradeNo());

        Map<String, Object> requestParameter = new HashMap();
        requestParameter.put("app_id", "2015052600090779");
        requestParameter.put("method", "alipay.trade.app.pay");
        requestParameter.put("format", "JSON");
        requestParameter.put("charset", "utf-8");
        requestParameter.put("sign_type", "RSA2");
        requestParameter.put("sign", "ae7ed8d3f64c481b819bd777c8c6bdfaae7ed8d3f64c481b819bd777c8c6bdfa");
        requestParameter.put("timestamp", "2023-11-04 13:07:50");
        requestParameter.put("version", "2.0");
        requestParameter.put("notify_url", tradeOrder.getNotifyUrl());
        requestParameter.put("biz_content", bizContent);
        return requestParameter;
    }

}
